<template>
    <a-card :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
            <a-form layout="inline" @keyup.enter.native="searchQuery">
                <a-row :gutter="24">
                    <a-col :md="6" :sm="8">
                        <a-form-item label="分组">
                            <a-select v-model="queryParam.flmc" placeholder="请选择分组名称" @change="handleSelectFz">
                                <a-select-option v-for="item in fsfzlist" :key="item.fl_mc" :value="item.fl_mc">
                                    {{ item.fl_mc }}
                                </a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>
                    <a-col :span="12" :sm="12">
                        <div class="tjdata">
                            <span>总数量：<span class="count">{{ reviewStatistics.sum }}</span></span>
                            <span>已评分：<span class="count">{{ reviewStatistics.ypf }}</span></span>
                            <!-- <span>暂存：</span> -->
                            <span>未评分：<span class="count">{{ reviewStatistics.wpf }}</span></span>
                            <span>评分状态: <span
                                    class="count">{{ reviewStatistics.pfzt == 0 ? '未提交' : reviewStatistics.pfzt == 1 ? '已提交' :
                                            ''
                                    }}</span></span>
                            <a-button type="primary" style="margin: 0px;"
                                :disabled="reviewStatistics.pfzt == 0 ? false : reviewStatistics.pfzt == 1 ? true : ''"
                                @click="submitAll(reviewStatistics)">全部提交</a-button>
                          <!-- 隐藏签名按钮
                            <a-button type="primary" style="margin: 0px 0 0 10px;"
                                :disabled="disabledSig"
                                @click="submitQrode(reviewStatistics)">签名</a-button>
                            <a-button type="primary" style="margin: 0px 0 0 10px;"
                                :disabled="!isTp || !disabledSig">评分预览
                            </a-button>
                            -->
                        </div>
                    </a-col>
                    <!-- <a-col :span="6" :sm="6">
                        <a-button type="primary" style="margin: 0px;" :disabled="reviewStatistics.pfzt==0?false:reviewStatistics.pfzt==1?true:''" @click="submitAll(reviewStatistics)">全部提交</a-button>
                    </a-col> -->
                </a-row>
            </a-form>
            <p style="color: #ff0000;font-size: 16px;">该组成果全部评审完成后，点击"全部提交"完成评分，提交后不可修改。</p>
        </div>
        <!-- 查询区域-END -->
        <!-- 操作按钮区域 高级查询区域-->
        <div class="table-operator" style="display: flex; align-items: center;justify-content: space-between;"></div>
        <!-- table区域-begin -->
        <div>
            <h2 style="text-align:center;font-size: 20px;">
                {{ new Date().getFullYear() }}年度电力创新奖特等奖评分表
                <!-- <a-button type="primary" style="margin: 0px;" @click="downloadFile">初审表下载</a-button> -->
            </h2>
            <!-- tableLayout="auto" -->
            <a-table ref="table" size="middle" :scroll="{ x: 1100 }" bordered rowKey="cxj_xmbh" :columns="columns"
                :dataSource="dataSource" :pagination="ipagination" :loading="loading" class="j-table-force-nowrap"
                @change="handleTableChange">
                <template
                    v-for="col in ['djps_xmcs', 'djps_cxx', 'djps_xjx', 'djps_jjxy', 'djps_tdzy', 'djps_yyqj', 'fs_tgjz']"
                    :slot="col" slot-scope="text, record, index">
                    <div :key="col">
                        <a-popover placement="top" v-if="record.editable">
                            <template slot="content">
                                <div v-if="col == 'djps_xmcs'">
                                    <p>第一完成人答辩，材料准备充分，陈述十分流畅，语言简练；能有效、全面解答问题，表达清晰，论证严谨，2分</p>
                                    <p>材料准备基本充分，陈述基本清晰，基本能正确回答问题，1分</p>
                                    <p>仅能完成项目陈述，表达流畅程度一般；仅能回答部分问题，0分</p>
                                </div>
                                <div v-else-if="col == 'djps_cxx'">
                                    <p>有重大创新，创新难度大，有自主知识产权，21-25分</p>
                                    <p>有较大创新，技术难度较大，10-20分</p>
                                    <p>有一定创新，有一定技术难度，0-9分</p>
                                </div>
                                <div v-else-if="col == 'djps_xjx'">
                                    <p>达到或接近国际同类技术先进水平，21-25分</p>
                                    <p>居国内同类技术领先水平，10-20分</p>
                                    <p>达到国内同类技术先进水平，0-9分</p>
                                </div>
                              <!--
                                <div v-else-if="col == 'djps_jjxy'">
                                    <p>对企业管理水平和生产效率有很大提升，效益重大，14-18分</p>
                                    <p>对企业的管理水平和生产效率有较大提升，效益较大，9-13分</p>
                                    <p>对企业的管理水平和生产效率有一定提升，有一定效益，0-8分</p>
                                </div>
                                -->
                              <div v-else-if="col == 'djps_jjxy'">
                                <p>对提高企业生产效率、安全稳定运行效果显著，有重大的经济效益和社会效益，14-18分</p>
                                <p>对提高企业生产效率、安全稳定运行效果明显，有较大的经济效益和社会效益，9-13分</p>
                                <p>对提高企业生产效率、安全稳定运行效果一般，有一定的经济效益和社会效益，0-8分</p>
                              </div>
                                <div v-else-if="col == 'djps_yyqj'">
                                    <p>实用化程度高，具有很大的推广应用前景，12-15分</p>
                                    <p>实用化程度较高，具有较大的推广应用前景，7-11分</p>
                                    <p>满足实用化要求，有一定推广应用前景，0-6分</p>
                                </div>
                                <div v-else-if="col == 'djps_tdzy'">
                                    <p>促进作用重大，12-15分</p>
                                    <p>促进作用较大，7-11分</p>
                                    <p>有一定促进作用，0-6分</p>
                                </div>
                                <div v-else-if="col == 'fs_tgjz'">
                                    <p>实现了技术跨越，对科技进步促进作用重大，8-10分</p>
                                    <p>技术水平明显提高，对科技进步促进作用较大，4-7分</p>
                                    <p>技术水平有一定提高，对科技进步有一定促进作用，0-3分</p>
                                </div>
                            </template>
                            <a-input type="number" style="margin: -5px 0" :value="text"
                                @change="e => handleChange(e.target.value, record.key, col)" />
                        </a-popover>
                        <template v-else>
                            {{ text }}
                        </template>
                    </div>
                </template>
                <!-- <template slot="djps_pingshenyj" slot-scope="text, record, index">
                    <div key="djps_pingshenyj">
                        <a-textarea
                            :value="text"
                            v-if="record.editable"
                            placeholder="请填写评审意见"
                            @change="e => handleChange(e.target.value, record.key, 'djps_pingshenyj')"
                            :auto-size="{ minRows: 1, maxRows: 5 }"
                        />
                        <template v-else>
                            {{ text }}
                        </template>
                    </div>
                </template> -->
                <template slot="djps_sfhb" slot-scope="text, record">
                    <div key="djps_sfhb">
                        <a-radio-group default-value="N" v-model="record.djps_sfhb">
                            <a-radio value="Y" :disabled="!record.editable">是</a-radio>
                            <a-radio value="N" :disabled="!record.editable">否</a-radio>
                        </a-radio-group>
                    </div>
                </template>
                <span slot="cxj_xmbh" slot-scope="text, record">
                    <span>{{ record.cxj_xmbh }}</span>
                    <!-- <span>{{record.sfzs}}</span> -->
                    <span v-if="record.sfzs" style="color:#ff0000;font-weight:bold;">({{ record.sfzs }})</span>
                    <span v-else style="color:#ff0000;font-weight:bold;">{{ record.sfzs }}</span>
                </span>
                <span slot="cgzlAction" slot-scope="text, record">
                    <a @click="handlePreview(record)">查看</a>
                </span>
                <span slot="djps_zongfen" slot-scope="text, record" class="djps_zongfen">
                    <span>{{ record.djps_zongfen }}</span>
                </span>
                <template slot="action" slot-scope="text, record, index">
                    <div v-if="userRole == 3" class="editable-row-operations">
                        <span v-if="!record.editable">
                            <a v-if="record.fs_zhuangtai==1" disabled>评分</a>
                            <!-- <a v-if="record.fs_zhuangtai == 1">评分</a> -->
                            <a v-else :disabled="editingKey !== '' ? true : false"
                                @click="() => edit(record.key)">评分</a>
                        </span>
                        <!-- <a-divider type="vertical" /> -->
                        <span v-else>
                            <a @click="() => save(record.key, record)">保存</a>
                            <a-popconfirm title="真的放弃编辑吗?" @confirm="() => cancel(record.key)">
                                <a>取消</a>
                            </a-popconfirm>
                        </span>
                    </div>
                </template>
            </a-table>
        </div>
        <cxj-jscs-pf-js-modal ref="modalForm" @ok="modalFormOk"></cxj-jscs-pf-js-modal>
        <!-- 二维码 -->
        <a-modal :visible="qrcodeVisible" @cancel="handleCancel()" title="请用手机扫二维码签名" centered :footer="null"
            width="400px" height="400px">
            <vue-qr :text="imgQrUrl" :size="360" :margin="0"></vue-qr>
        </a-modal>
        <!-- pdf -->
        <view-pdf :params="pafParams" :showPdf="showpdf" @reset="getQrUrl" :pafBtn="pafBtn" path="cxjDjpsPf"></view-pdf>
    </a-card>
</template>

<script>
import VueQr from 'vue-qr'
import viewPdf from '@/views/cxj/viewPdf'
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import CxjJscsPfJsModal from './modules/CxjJscsPfJsModal'
import { getAction, postAction } from '../../api/manage'
import qs from 'qs';
import Vue from 'vue'
import { USER_INFO, ACCESS_TOKEN } from "@/store/mutation-types"
import {
    // 复审分组专家表-获取分组列表
    cxjFsGetZjFz,
    // 复审项目评分表-技术类-获取分组项目
    cxjdjpsGetFzxmListByFzid,
    // 复审项目评分表-技术类-评分保存或修改
    cxjdjpsSavePf,
    // 技术复审评分表-评分统计-专家
    cxjdjpsPfTjZj,
    cxjzxpdSubmitStatusTpJs,
    cxjzxpdIsShowSig,
    cxjDjpsPfGetOrcode
} from "@/api/api";
import { cxjdjpsSubmitPf } from '@/api/manage'
import moment from 'moment';
import {
    // 技术初审评分表-导出
    jscsPfExport
} from "@/api/manage"
export default {
    name: 'CxjJscsPfJsList',
    // mixins:[JeecgListMixin, mixinDevice],
    mixins: [mixinDevice],
    components: {
        CxjJscsPfJsModal,
        VueQr,
        viewPdf
    },
    computed: {
        columns() {
            let { sortedInfo } = this;
            sortedInfo = sortedInfo || {};
            const columns = [
                {
                    title: '答辩序号',
                    dataIndex: 'xm_xh',
                    key: 'rowIndex',
                    width: '4%',
                    align: "center",
                },
                {
                    title: '成果编号',
                    align: "center",
                    dataIndex: 'cxj_xmbh',
                    width: '8%',
                    scopedSlots: { customRender: 'cxj_xmbh' },
                },
                {
                    title: '成果名称',
                    dataIndex: 'cxj_mc_zw',
                },
                {
                    title: '成果资料',
                    align: "center",
                    dataIndex: 'cgzlAction',
                    width: '4%',
                    scopedSlots: { customRender: 'cgzlAction' }
                },
                {
                    title: '审查意见',
                    width: '36%',
                    align: 'center',
                    children: [
                        {
                            title: '项目陈述',
                            align: "center",
                            width: '6%',
                            children: [{
                                title: "2分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_xmcs",
                                scopedSlots: { customRender: 'djps_xmcs' }
                            }]
                        },
                        {
                            title: '创新程度',
                            align: "center",
                            width: '6%',
                            children: [{
                                title: "25分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_cxx",
                                scopedSlots: { customRender: 'djps_cxx' }
                            }]
                        },
                        {
                            title: '先进程度',
                            align: "center",
                            width: '6%',
                            children: [{
                                title: "25分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_xjx",
                                scopedSlots: { customRender: 'djps_xjx' }
                            }]
                        },
                        {
                            title: '经济效益或社会效益',
                            align: "center",
                            width: '6%',
                            children: [{
                                title: "18分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_jjxy",
                                scopedSlots: { customRender: 'djps_jjxy' }
                            }]
                        },
                        {
                            title: '实用化程度与推广应用前景',
                            width: '6%',
                            children: [{
                                title: "15分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_yyqj",
                                scopedSlots: { customRender: 'djps_yyqj' }
                            }]
                        },
                        {
                            title: '推动电力行业发展的作用',
                            align: "center",
                            width: '6%',
                            children: [{
                                title: "15分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_tdzy",
                                scopedSlots: { customRender: 'djps_tdzy' }
                            }]
                        },
                        {
                            title: '合计',
                            align: "center",
                            width: '5%',
                            dataIndex: 'djps_zongfen',
                            scopedSlots: { customRender: 'djps_zongfen' },
                            sorter: (a, b) => b.djps_zongfen - a.djps_zongfen,
                            sortOrder: sortedInfo.columnKey === 'djps_zongfen' && sortedInfo.order
                        },
                        {
                            title: '是否回避',
                            dataIndex: 'djps_sfhb',
                            width: '10%',
                            scopedSlots: { customRender: 'djps_sfhb' }
                        }
                    ]
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    align: "center",
                    fixed: "right",
                    width: 90,
                    scopedSlots: { customRender: 'action' }
                }
            ]
            return columns;
        },
    },
    data() {
        // this.cacheData = dataSource.map(item => ({ ...item }));
        return {
            sortedInfo: null,
            pdfFilePath: '',
            showpdf: false,
            pafBtn: false,
            signStatus: false,
            pafParams: {},
            qrcodeVisible: false,
            imgQrUrl: '',
            xszjfzData: [],
            cxjfsDbsjlist: [],
            dbsj: '',
            cxj_fs_fz_id: '',
            reviewStatistics: '',
            cacheData: [],
            fsfzlist: [],
            description: '初审项目评分表-技术类-获取分组项目',
            disabledSig: true,
            // 表头
            /* columns: [
                {
                    title: '答辩序号',
                    dataIndex: 'xm_xh',
                    key: 'rowIndex',
                    width: '4%',
                    align: "center",
                },
                {
                    title: '成果编号',
                    align: "center",
                    dataIndex: 'cxj_xmbh',
                    width: '8%',
                    scopedSlots: { customRender: 'cxj_xmbh' },
                },
                {
                    title: '成果名称',
                    dataIndex: 'cxj_mc_zw',
                },
                {
                    title: '成果资料',
                    align: "center",
                    dataIndex: 'cgzlAction',
                    width: '4%',
                    scopedSlots: { customRender: 'cgzlAction' }
                },
                {
                    title: '审查意见',
                    width: '36%',
                    align: 'center',
                    children: [
                        {
                            title: '项目陈述',
                            align: "center",
                            width: '6%',
                            children: [{
                                title: "2分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_xmcs",
                                scopedSlots: { customRender: 'djps_xmcs' }
                            }]
                        },
                        {
                            title: '创新程度',
                            align: "center",
                            width: '6%',
                            children: [{
                                title: "25分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_cxx",
                                scopedSlots: { customRender: 'djps_cxx' }
                            }]
                        },
                        {
                            title: '先进程度',
                            align: "center",
                            width: '6%',
                            children: [{
                                title: "25分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_xjx",
                                scopedSlots: { customRender: 'djps_xjx' }
                            }]
                        },
                        {
                            title: '经济效益或社会效益',
                            align: "center",
                            width: '6%',
                            children: [{
                                title: "18分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_jjxy",
                                scopedSlots: { customRender: 'djps_jjxy' }
                            }]
                        },
                        {
                            title: '实用化程度与推广应用前景',
                            width: '6%',
                            children: [{
                                title: "15分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_yyqj",
                                scopedSlots: { customRender: 'djps_yyqj' }
                            }]
                        },
                        {
                            title: '推动电力行业发展的作用',
                            align: "center",
                            width: '6%',
                            children: [{
                                title: "15分",
                                align: "center",
                                width: '6%',
                                dataIndex: "djps_tdzy",
                                scopedSlots: { customRender: 'djps_tdzy' }
                            }]
                        },
                        {
                            title: '合计',
                            align: "center",
                            width: '5%',
                            dataIndex: 'djps_zongfen',
                            scopedSlots: { customRender: 'djps_zongfen' },
                            sorter: (a, b) => b.djps_zongfen - a.djps_zongfen,
                        },
                        {
                            title: '是否回避',
                            dataIndex: 'djps_sfhb',
                            width: '10%',
                            scopedSlots: { customRender: 'djps_sfhb' }
                        }
                    ]
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    align: "center",
                    fixed: "right",
                    width: 90,
                    scopedSlots: { customRender: 'action' }
                }
            ], */
            url: {
                list: "/cxj/cxjJscsPfJs/list",
                delete: "/cxj/cxjJscsPfJs/delete",
                cxjdjps_fzlist: "/cxj/cxjDjpsXm/cxjdjps_getCgfl",
                deleteBatch: "/cxj/cxjJscsPfJs/deleteBatch",
                exportXlsUrl: "/cxj/cxjJscsPfJs/exportXls",
                importExcelUrl: "cxj/cxjJscsPfJs/importExcel",
                // 答辩时间列表
                cxjfs_dbsjlist: '/cxj/cxjFsSj/cxjfs_getDbsjListByFzid'
            },
            superFieldList: [],
            // 分组id
            fzid: "",
            editingKey: '',
            userRole: sessionStorage.getItem('role'),
            queryParam: {},
            dictOptions: {},
            fileStatus: "",
            selectedRowKeys: [],
            selectionRows: [],
            loading: false,
            isorter: {
                column: 'createTime',
                order: 'desc',
            },
            dataSource: [],
            ipagination: {
                current: 1,
                pageSize: 50,
                pageSizeOptions: ['20', '50', '100'],
                // pageSizeOptions: ['5', '10', '15'],
                showTotal: (total, range) => {
                    return range[0] + "-" + range[1] + " 共" + total + "条"
                },
                showQuickJumper: true,
                showSizeChanger: true,
                total: 0
            },
            currentData: [],
            currentParams: {
                p: {},
                k: {},
                o: {}
            },
            tag: 0
        }
    },
    created() {
        this.$set(this.dictOptions, 'isValid', [{ text: '是', value: 'Y' }, { text: '否', value: 'N' }])
        this.getSuperFieldList();
        // this.getcxjdjps_fzlist();
        this.fetchCxFsGetZjFz();
        // this.loadData();
    },
    watch: {
        dataSource() {
            this.updateDataSource();
        }
    },
    methods: {
        moment,
        handleCancel() {
            clearInterval(this.qrTimer)
            this.qrcodeVisible = false;
        },
        // 评分预览
        ratingPreview(flag) {
            this.pafBtn = flag == 1 ? false : true
            let user = Vue.ls.get(USER_INFO);
            this.pafParams = {
                fzid: 111,
                zjid: user.id
            }
            this.showpdf = !this.showpdf
        },
        // 查询签名状态
        checkSignStatus(params) {
            clearInterval(this.qrTimer)
            this.qrTimer = setInterval(() => {
                cxjzxpdSubmitStatusTpJs(params, 'cxjDjpsPf').then(res => {
                    if (res.result) {
                        clearInterval(this.qrTimer)
                        this.qrcodeVisible = false
                        this.signStatus = true
                        this.ratingPreview(1)
                        this.$message.success("签名成功！")
                        this.isShowSigFun()
                    }
                }).catch(err => {
                    this.$message.error("查询签名状态失败！")
                })
            }, 1000)
        },
        submitQrode(record) {
            this.getQrUrl()
        },
        // 查询二维码地址
        getQrUrl() {
            let user = Vue.ls.get(USER_INFO);
            let that = this
            let formData = new FormData();
            formData.append('zjid', user.id)
            cxjDjpsPfGetOrcode(formData).then(res => {
                if (res.code === 200) {
                    this.imgQrUrl = `${window.location.origin}${res.result}&path=cxjDjpsPf`
                    this.qrcodeVisible = true
                    this.checkSignStatus({
                        fzid: 111,
                        zjid: user.id
                    })
                } else {
                    this.$message.error(res.message)
                }
            }).catch(err => {
                this.$message.error("查询二维码失败！")
            })
        },
        // 获取答辩时间列表
        // getDbTimeList(){
        //     postAction(this.url.cxjfs_dbsjlist, qs.stringify({fzid:this.fzid})).then((res) => {
        //         if (res.success) {
        //             this.cxjfsDbsjlist = res.result.records || res.result;
        //             this.cxjfsDbsjlist.unshift({
        //                 fs_sj_rq:"全部",
        //                 id: 'all'
        //             })
        //         }
        //         if (res.code === 510) {
        //             this.$message.warning(res.message)
        //         }
        //     })
        // },
        // 获取分组列表【用于技术类-获取分组项目列表参数fzid】
        fetchCxFsGetZjFz() {
            let user = Vue.ls.get(USER_INFO);
            this.getcxjdjps_fzlist();
            // cxjFsGetZjFz({sysZjId: user.id, flbh: 11}).then(res=>{
            //     // console.log(res)
            //     if(res.success) {
            //         if (res.result.length) {
            //             // console.log('分组', res.result)
            //             this.xszjfzData = res.result;
            //             this.fzid = res.result[0].cxj_fs_fz_id;
            //             this.cxj_fs_fz_id = res.result[0].cxj_fs_fz_id;
            //         }
            //         this.getDbTimeList();
            //         this.loadData();
            //         this.getjsfsPfTjZj();
            //     }
            // })
        },
        getcxjdjps_fzlist() {
            var shijian = moment(new Date()).format('YYYY');
            getAction(this.url.cxjdjps_fzlist, {
                shijian: shijian
            }).then((res) => {
                if (res.success) {
                    this.fsfzlist = res.result.records || res.result;
                    this.flmc = res.result[0].fl_mc || res.result.records[0].fl_mc;
                    // this.cxj_fs_fz_id = res.result[0].fl_id || res.result.records[0].fl_id;
                }
                // this.getDbTimeList();
                this.loadData();
                this.getjsfsPfTjZj();
            })
        },
        updateDataSource() {
            this.dataSource.map(item => {
                item.djps_zongfen = Number(item.djps_xmcs) + Number(item.djps_cxx) + Number(item.djps_xjx) + Number(item.djps_tdzy) + Number(item.djps_yyqj) + Number(item.djps_jjxy);
            })
        },
        // 切换分组
        handleSelectFz(value) {
            this.flmc = value;
            this.editingKey = '';
            this.getjsfsPfTjZj();
            this.loadData(1);
        },
        // 切换答辩时间
        handleTime(value) {
            this.fetchCxFsGetZjFz();
        },
        // 获取技术初审评分表-评分统计
        getjsfsPfTjZj() {
            let formData = new FormData();
            formData.append('flmc', this.flmc)
            cxjdjpsPfTjZj(formData).then(res => {
                if (res.code == 200) {
                    this.reviewStatistics = res.result;
                } else {
                    this.$message.warning(res.message)
                }
            })
        },
        // 全部提交
        submitAll(record) {
            // console.log(record)
            let that = this;
            if (record.ypf == record.sum) {
                let user = Vue.ls.get(USER_INFO);
                let formData = new FormData();
                formData.append('flmc', this.flmc)
                formData.append('zjid', user.id)
                this.$confirm({
                    title: '确定要全部提交吗?',
                    okText: '确定',
                    cancelText: '取消',
                    onOk() {
                        // cxjdjpsSubmitPf(formData).then(res=>{
                        cxjdjpsSubmitPf({
                            "flmc": that.flmc,
                            "zjid": user.id
                        }).then(res => {
                            // console.log('--------',res)
                            if (res.code == 200) {
                                that.$message.success(res.message);
                                // that.fetchCxFsGetZjFz();
                                that.loadData();
                                that.getjsfsPfTjZj();
                            } else {
                                that.$message.warning(res.message);
                                // that.fetchCxFsGetZjFz();
                                that.loadData();
                                that.getjsfsPfTjZj();
                            }
                        })
                    },
                    onCancel() {
                        // console.log('Cancel');
                    },
                });
            } else {
                this.$message.warning("还未完成评分，无法提交！")
            }
        },
        resetSearchForm() {
            this.fetchCxFsGetZjFz();
        },
        // 初审表下载
        // downloadFile(){
        //     console.log('初审表下载')
        //     let data = {
        //         fzid: this.cxj_fs_fz_id
        //     }
        //     jscsPfExport(data).then(res=>{
        //         this.downfn('初审表下载',res);
        //     })
        // },
        downfn(name, res) {
            const _res = res;
            let blob = new Blob([_res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
            let downloadElement = document.createElement("a");
            let href = window.URL.createObjectURL(blob); //创建下载的链接
            downloadElement.href = href;
            downloadElement.download = name; //下载后文件名
            document.body.appendChild(downloadElement);
            downloadElement.click(); //点击下载
            document.body.removeChild(downloadElement); //下载完成移除元素
            window.URL.revokeObjectURL(href); //释放掉blob对象
        },
        // 查看
        handlePreview(record) {
            // console.log('查看', record.cxj_cxj_id)
            let token = Vue.ls.get(ACCESS_TOKEN);
            sessionStorage.setItem('token', token);
            let routeData = this.$router.resolve({
                path: '/shenbao/declare',
                query: {
                    type: record.fl_id,
                    cxj_cxj_id: record.cxj_cxj_id,
                    isHead: 2,
                    from: 'zj',
                    xmztbh: record.xmztbh,
                    cxj_xmbh: record.cxj_xmbh,
                    cxj_mc_zw: record.cxj_mc_zw
                }
            });
            window.open(routeData.href, '_blank');
        },

        /* 对行内进行修改开始 */
        handleChange(value, key, column) {
            console.log('handleChange===', value, key, column)
            // this.sortedInfo = column;
            // console.log('column===',column)
            const newData = [...this.dataSource];
            const target = newData.filter(item => key === item.key)[0];
            // console.log('target',target)
            if (column == 'djps_xmcs' && value > 2) {
                value = 2;
            } else if (column == 'djps_cxx' && value > 25) {
                value = 25;
            } else if (column == 'djps_xjx' && value > 25) {
                value = 25;
            } else if (column == 'djps_jjxy' && value > 18) {
                value = 18;
            } else if (column == 'djps_tdzy' && value > 15) {
                value = 15;
            } else if (column == 'djps_yyqj' && value > 15) {
                value = 15;
            }
            if (target) {
                target[column] = value;
                // console.log('target[column]',target[column])
                this.dataSource = newData;
                // console.log('input',this.dataSource)
            }
        },
        edit(key) {
            // this.loadData();
            console.log('key==', key, this.dataSource[key], this.columns)
            let newData = [];
            if (this.sortedInfo == null || this.sortedInfo.order == '') {
                newData = [...this.dataSource];
            } else {
                newData = [...this.currentData];
                this.sortedInfo.order = ''
            }
            const target = newData.filter(item => key === item.key)[0];
            this.editingKey = key;
            if (target) {
                target.editable = true;
                this.dataSource = newData;
            }
        },
        save(key, record) {
            // if (record.sfzs == '主审') {
            //     if (!record.djps_pingshenyj) {
            //         this.$message.warning('请填写评审意见');
            //         return;
            //     }
            // }
            const newData = [...this.dataSource];
            const newCacheData = [...this.cacheData];
            const target = newData.filter(item => key === item.key)[0];
            const targetCache = newCacheData.filter(item => key === item.key)[0];
            if (target && targetCache) {
                delete target.editable;
                this.dataSource = newData;
                Object.assign(targetCache, target);
                this.cacheData = newCacheData;
            }
            this.editingKey = '';
            let formData = {};
            if (record.djps_sfhb == 'Y') {
                formData = {
                    // 项目陈述
                    djpsXmcs: '',
                    // 专家提问及应答
                    djpsCxx: '',
                    // 技术创新程度
                    djpsXjx: '',
                    // 经济效益或社会效益
                    djpsTdzy: '',
                    // 评审意见
                    // djpsPingshenyj: record.djps_pingshenyj,
                    djpsSfhb: record.djps_sfhb,
                    // 技术创新对提高市场竞争能力的作用
                    djpsYyqj: '',
                    // 推动电力科技进步的作用
                    // fsTgjz: record.fs_tgjz,
                    // 技术经济指标的先进程度
                    djpsJjxy: '',
                    // 总分
                    djpsZongfen: '',
                    cxjCxjId: record.cxj_cxj_id,
                    id: record.id,
                    fsZhuangtai: record.fs_zhuangtai
                }
            } else {
                formData = {
                    // 项目陈述
                    djpsXmcs: record.djps_xmcs,
                    // 专家提问及应答
                    djpsCxx: record.djps_cxx,
                    // 技术创新程度
                    djpsXjx: record.djps_xjx,
                    // 经济效益或社会效益
                    djpsTdzy: record.djps_tdzy,
                    // 评审意见
                    // djpsPingshenyj: record.djps_pingshenyj,
                    djpsSfhb: record.djps_sfhb,
                    // 技术创新对提高市场竞争能力的作用
                    djpsYyqj: record.djps_yyqj,
                    // 推动电力科技进步的作用
                    // fsTgjz: record.fs_tgjz,
                    // 技术经济指标的先进程度
                    djpsJjxy: record.djps_jjxy,
                    // 总分
                    djpsZongfen: record.djps_zongfen,
                    cxjCxjId: record.cxj_cxj_id,
                    id: record.id,
                    fsZhuangtai: record.fs_zhuangtai
                }
            }
            console.log('技术复审', formData)
            cxjdjpsSavePf(formData).then(res => {
                if (res.code == 200) {
                    this.$message.success(res.message);
                    this.loadData();
                    this.getjsfsPfTjZj();
                } else {
                    this.$message.warning(res.message);
                    this.loadData();
                    this.getjsfsPfTjZj();
                }
            })
        },
        cancel(key) {
            const newData = [...this.dataSource];
            const target = newData.filter(item => key === item.key)[0];
            this.editingKey = '';
            if (target) {
                Object.assign(target, this.cacheData.filter(item => key === item.key)[0]);
                delete target.editable;
                this.dataSource = newData;
            }
            this.loadData();
        },
        /* 对行内进行修改结束 */

        /* 获取列表固定格式开始 */
        getQueryField() {
            //TODO 字段权限控制
            var str = "id,";
            this.columns.forEach(function (value) {
                str += "," + value.dataIndex;
            });
            return str;
        },
        // 获取分组项目
        loadData(arg) {
            console.log(343434)
            if (arg === 1) {
                this.ipagination.current = 1;
            }
            this.loading = true;
            let user = Vue.ls.get(USER_INFO);

            // console.log('专家信息',user)
            let params = Object.assign(this.queryParam, this.isorter, this.filters)
            params.field = this.getQueryField();
            params.pageNo = this.ipagination.current;
            params.pageSize = this.ipagination.pageSize;
            params.flmc = this.flmc;
            // cxjzxpdSubmitStatusTpJs(params, 'cxjDjpsPf').then(res => {
            //     if (res.result) {
            //         this.signStatus = true;
            //     } else {
            //         this.signStatus = false;
            //     }
            // }).catch(err => {
            //     this.$message.error("查询签名状态失败！")
            // })
            this.isShowSigFun()
            cxjdjpsGetFzxmListByFzid(qs.stringify(params)).then(res => {
                // console.log('获取分组项目',res)
                if (res.success) {
                    this.dataSource = res.result.records || res.result;
                    this.dataSource.map((item, index) => {
                        item.key = index;
                        if (!item.djps_sfhb) {
                            item.djps_sfhb = "N";
                        }
                    })
                    this.cacheData = this.dataSource;
                    if (res.result.total) {
                        this.ipagination.total = res.result.total;
                    } else {
                        this.ipagination.total = 0;
                    }
                    // this.isorter.order = "ascend"
                }
                if (res.code === 510) {
                    this.$message.warning(res.message)
                }
                this.loading = false;
            })
            /* this.columns.map((item, index)=>{
                if (index == 4) {
                    item.children.map((list, ind)=>{
                        if (ind == 6 && list.sortOrder == "ascend" || list.sortOrder == "descend") {
                            // list.sortOrder = undefined;
                            console.log('list.sortOrder==',list.sortOrder)
                        }
                    })
                }
            }) */
        },
        isShowSigFun(){
          cxjzxpdIsShowSig(this.params,'cxjDjpsPf').then(res=>{
            if (res.result) {
              this.disabledSig = false
            } else {
              this.disabledSig = true
            }
          }).catch(err => {
            this.$message.error("查询签名状态失败！")
          })
        },
        onSelectChange(selectedRowKeys, selectionRows) {
            this.selectedRowKeys = selectedRowKeys;
            this.selectionRows = selectionRows;
        },
        onClearSelected() {
            this.selectedRowKeys = [];
            this.selectionRows = [];
        },
        modalFormOk() {
            // 新增/修改 成功时，重载列表
            this.loadData();
            //清空列表选中
            this.onClearSelected()
        },
        handleTableChange(pagination, filters, sorter, { currentDataSource }) {
            //分页、排序、筛选变化时触发
            //TODO 筛选
            this.sortedInfo = sorter;
            this.sortStatus = sorter.order;
            // 用于解决操作一行数据时：未保存状态下，对齐进行排序操作，【评分】按钮无法点击的问题
            this.editingKey = '';
            this.ipagination = pagination;
            // console.log('this.editingKey==',this.editingKey)
            console.log('sorter===', sorter)
            if (Object.keys(sorter).length > 0) {
                if (this.editingKey) { } else {
                    this.loadData();
                }
                this.isorter.column = sorter.field;
                this.isorter.order = "ascend" == sorter.order ? "asc" : "desc";
            } else {
                this.loadData();
            }
            this.currentData = currentDataSource


            // this.loadData();
            // if (Object.keys(sorter).length > 0) {
            //     this.isorter.column = sorter.field;
            //     this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
            // }
            // this.ipagination = pagination;
            // this.loadData();
        },
        searchQuery() {
            // this.loadData(1);
            this.fetchCxFsGetZjFz();
        },
        searchReset() {
            // this.queryParam = {};
            // this.getDbTimeList();
            this.fetchCxFsGetZjFz();
            // this.dbsj = '';
        },
        /* 获取列表固定格式结束 */





        initDictConfig() { },
        getSuperFieldList() {
            let fieldList = [];
            fieldList.push({ type: 'string', value: 'sysZjId', text: '专家ID', dictCode: '' })
            fieldList.push({ type: 'string', value: 'cxjCxjId', text: '成果ID', dictCode: '' })
            fieldList.push({ type: 'double', value: 'jscsCxx', text: '技术创新性', dictCode: '' })
            fieldList.push({ type: 'double', value: 'jscsXjx', text: '技术先进性', dictCode: '' })
            fieldList.push({ type: 'double', value: 'jscsSsxg', text: '实用化程度', dictCode: '' })
            fieldList.push({ type: 'double', value: 'jscsJjxy', text: '经济效益', dictCode: '' })
            fieldList.push({ type: 'double', value: 'jscsTgjz', text: '推动作用', dictCode: '' })
            fieldList.push({ type: 'string', value: 'jscsPingjiayj', text: '评审意见', dictCode: '' })
            fieldList.push({ type: 'double', value: 'jscsZongfen', text: '总分', dictCode: '' })
            fieldList.push({ type: 'string', value: 'jscsZt', text: '评分状态', dictCode: '' })
            fieldList.push({ type: 'string', value: 'shijian', text: '年度', dictCode: '' })
            fieldList.push({ type: 'string', value: 'bz1', text: '备注1', dictCode: '' })
            fieldList.push({ type: 'string', value: 'bz2', text: '备注2', dictCode: '' })
            fieldList.push({ type: 'string', value: 'bz3', text: '备注3', dictCode: '' })
            fieldList.push({ type: 'switch', value: 'isValid', text: '是否有效' })
            this.superFieldList = fieldList
        }
    }
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
/deep/* {
  font-size: 14px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
/deep/.ant-table-tbody > tr > td {
  word-break: break-all;
  white-space: normal;
  word-wrap:break-word;
  font-size:14px;
  padding:6px 3px!important;
}
/deep/.ant-table-tbody > tr > td > div {
  font-size: 14px;
}

/deep/.ant-table-thead > tr > th {
  word-break: break-all;
  white-space: normal;
  word-wrap:break-word;
  text-align: center;
  font-size:14px;
  padding:5px 3px!important;
}
.editable-row-operations a {
  margin-right: 8px;
}
.tjdata {
  // margin-top: 20px;
  span {
    margin-right:20px;
    line-height: 30px;
    font-size: 16px;
  }
}
.count {
  color: #ee9900;
  font-weight: 700;
  font-size: 16px;
}
/deep/.ant-table-tbody > tr > td:nth-child(12) {
  color: #ee9900!important;
  font-weight: 700;
  font-size: 16px;
}
.editable-row-operations a {
  margin: 0px 2px;
}
  .table-page-search-wrapper .anty-form-btn .ant-form-item {
    margin-bottom: 10px;
  }
  .djps_zongfen {
    color: #ee9900;
    font-weight: bold;
  }
</style>